//修改tree数据
export function updateItemById(arr, id, key, type, num) {
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].id === id) {
      if (type == 'add') {
        arr[i][key] += num
      }
      if (type == 'del') {
        arr[i][key] -= num
      }
      return true
    } else if (arr[i].children) {
      if (updateItemById(arr[i].children, id, key, type, num)) {
        return true
      }
    }
  }
  return false
}
